Page({
  data: {
    question: '',
    score: 0,
    wordBank: ['apple', 'banana', 'car']
  },
  onLoad() {
    this.setQuestion();
  },
  setQuestion() {
    const index = Math.floor(Math.random() * this.data.wordBank.length);
    this.setData({
      question: '请填写英文单词：' + this.data.wordBank[index]
    });
  },
  checkAnswer(e) {
    const answer = e.detail.value;
    const correctAnswer = this.data.wordBank.find(word => word === answer);
    if (correctAnswer) {
      this.setData({
        score: this.data.score + 5
      });
      this.setQuestion();
    }
  }
})